﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Entetities;

namespace DAL
{
    public class NhaSanXuatDAL
    {
        DataHelper dh;
        public NhaSanXuatDAL()
        {
            dh = new DataHelper();
        }
        public List<NhaSanXuat> getNhaSanXuatByNhom1(int manhom)
        {
            List<NhaSanXuat> list = new List<NhaSanXuat>();
            SqlParameter para = new SqlParameter("@manhom", manhom);
            SqlDataReader sqlReader = dh.ExecuteReader("nhasanxuat_gettheonhom", para);
            while (sqlReader.Read())
            {
                NhaSanXuat oj = new NhaSanXuat();
                oj.Manhasanxuat = (int)sqlReader["Manhasanxuat"];
                oj.TenNhasanXuat = sqlReader["Tennhasanxuat"].ToString();
                oj.Tenanhdaidien = sqlReader["Tenanhdaidien"].ToString();
                oj.Anhdaidien = sqlReader["Anhdaidien"].ToString();
                oj.Mota = sqlReader["Mota"].ToString();
                list.Add(oj);
            }
            return list;
        }

        public DataTable getNhaSanXuatByNhom(int manhom)
        {
            DataTable dt = new System.Data.DataTable();
            SqlParameter para = new SqlParameter("@manhom", manhom);
            try
            {
                dt = dh.FieldSortTableSP("nhasanxuat_gettheonhom", para);
            }
            catch (Exception)
            {
                
                throw;
            }
            return dt;
        }

        public DataTable getNhaSanXuatByID(int ID)
        {
            DataTable dt = new System.Data.DataTable();
            SqlParameter para = new SqlParameter("@manhasanxuat", ID);
            try
            {
                dt = dh.FieldSortTableSP("nsx_GetTheoMa", para);
            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }
    }
}
